package com.cqtczh.qhd.driver.acticity.user;

import httptools.HttpJsonTool;
import imageTools.ImageFactory;

import java.io.File;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.UUID;

import tools.L;
import tools.SD_Finder;

import javabeen.Area;
import javabeen.AreaBeenFromServe;
import javabeen.CarRoutHomeBeen;
import javabeen.CarTypeBeen;
import javabeen.MessageBeen;
import javabeen.SerializableMap;
import javabeen.UserInfoBeen;

import com.baidu.navisdk.ui.routeguide.fsm.RouteGuideFSM.IFSMDestStateListener;
import com.google.gson.reflect.TypeToken;
import com.lidroid.xutils.BitmapUtils;
import com.cqtczh.qhd.driver.AppContent;
import com.cqtczh.qhd.driver.R;
import com.cqtczh.qhd.driver.R.integer;
import com.cqtczh.qhd.driver.acticity.ProjectHomeActivity;
import com.cqtczh.qhd.driver.acticity.base.BaseActivity;
import com.cqtczh.qhd.driver.api.GagApi;
import com.cqtczh.qhd.driver.model.Car;
import com.cqtczh.qhd.driver.model.LoginUserInfo;
import com.cqtczh.qhd.driver.utils.Base64Util;
import com.cqtczh.qhd.driver.utils.FileUtils;
import com.cqtczh.qhd.driver.utils.SPUtils;

import View.CustomViewPager;
import View.DatePickerFragment;
import View.DatePickerFragment.onChoseData;
import android.R.bool;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.DatePickerDialog.OnDateSetListener;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.provider.MediaStore;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class MessageActivity extends BaseActivity implements OnClickListener {
	private LayoutInflater inflater;
	CustomViewPager viewPager;
	private TextView[] buttons;
	private TextView messageTab0, messageTab1, messageTab2;
	private List<View> pageViews;
	private View first;
	private View second;
	private View third;
	private ImageView drive_EditText;
	int i = 1;
	// 当前的页面数字
	private int pageNo = 0;
	/** 相机拍照时候保存的路径 */

	private BitmapFactory.Options options = new BitmapFactory.Options();
	/** 相册的RequestCode用于驾驶证的code */
	public static final int INTENT_REQUEST_CODE_ALBUM_FOR_DRIVERCARD = 0; // 相册的RequestCode用于驾驶证的code
	/** 照相的RequestCode用于驾驶证的code */
	public static final int INTENT_REQUEST_CODE_CAMERA_FOR_DRIVERCARD = 1; // 照相的RequestCode用于驾驶证的code
	/** 相册的RequestCode用于行驶证的CodetravelCard */
	public static final int INTENT_REQUEST_CODE_ALBUM_FOR_TRAVELCARD = 2; // 相册的RequestCode用于行驶证的CodetravelCard
	/** 照相的RequestCode用于行驶证的Code */
	public static final int INTENT_REQUEST_CODE_CAMERA_FOR_TRAVELCARD = 3; // 照相的RequestCode用于行驶证的Code
	/** 司机头像的上传 相册的RequestCode */
	public static final int INTENT_REQUEST_CODE_ALBUM_FOR_DRIVERHEADIMAGE = 4;
	/** 司机头像的上传照相的RequestCode */
	public static final int INTENT_REQUEST_CODE_CAMERA_FOR_DRIVERHEADIMAGE = 5;

	/** 相册司机的ID */
	public static final int INTENT_REQUEST_CODE_ALBUM_FOR_DRIVERID = 6;

	/** 相机司机的ID */
	public static final int INTENT_REQUEST_CODE_CAMERA_FOR_DRIVERID = 7;

	/** 相册车头照片 */
	public static final int INTENT_REQUEST_CODE_ALBUM_FOR_CARTOP = 8;

	/** 相机车头照片 */
	public static final int INTENT_REQUEST_CODE_CAMERA_FOR_CARTOP = 9;

	/** 相册车侧面照片 */
	public static final int INTENT_REQUEST_CODE_ALBUM_FOR_CARSIDE = 10;

	/** 相机车侧面照片 */
	public static final int INTENT_REQUEST_CODE_CAMERA_FOR_CARSIDE = 11;

	/** 相册车背后照片 */
	public static final int INTENT_REQUEST_CODE_ALBUM_FOR_CARHALF = 12;

	/** 相机车背后照片 */
	public static final int INTENT_REQUEST_CODE_CAMERA_FOR_CARHALF = 13;

	private int typeMark;
	private Car car = new Car();
	BitmapUtils bitmapUtils;

	BitmapUtils bitmap_from_sd;

	Bitmap bm;

	// 是否是登录的时候
	String reg;

	/*
	 * \\请填写您的生日
	 */
	// private EditText gender_EditText;

	/*
	 * \\请填写您的QQ号
	 */
	private EditText QQ_EditText;
	/*
	 * \\微信号
	 */
	private EditText weixin_EditText;
	/*
	 * 请填写您的汽车类型
	 */
	private TextView carType_EditText;
	/*
	 * \请填写您的车辆牌照
	 */
	private EditText carTag_EditText;
	/*
	 * 请填写您的常跑线路
	 */
	private TextView oftenRun_EditText;
	/*
	 * 常驻车地址
	 */
	private TextView oftenStay_EditText;
	/*
	 * 真实姓名
	 */
	private EditText realName_EditText;

	/* * 请填写您的身份证号 */
	private EditText ID_EditText;
	/*
	 * 请添加驾您的驶证扫描件
	 */
	/** 用户信息 */
	public Map<String, Object> infoMap;

	/** 序列化的MAP */
	public SerializableMap serializable_infoMap;

	/** 全局图片 */
	public Map<String, String> imageMap;

	/** 图片路径 */
	public String mTakePicturePath;

	/** user_head 用户头像 */
	public ImageView user_head;
	/**
	 * activity容易被回收用来保存临时数据
	 */
	private Bundle infobundle;

	/**
	 * 
	 */
	private Bundle imagebundle;

	// /**
	// * 已经选择的常在地区的数量
	// */
	// private int oftenStayCount=0;
	//
	// /**
	// * 常驻地区的数量
	// */
	// private int oftenRunCount=0;

	// private List<Map<String, Object>> oftenAddressList ;

	/*
	 * 
	 * EditText editText=(EditText) findViewById(R.id.gender_EditText); EditText
	 * editText2=(EditText) findViewById(R.id.QQ_EditText); EditText
	 * editText3=(EditText)findViewById(R.id.weixin_EditText);
	 */

	/** 全局数据保存 */
	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * android.support.v4.view.ViewPager.OnPageChangeListener#onPageSelected
	 * (int)
	 * 
	 * KEY KEY说明 Vaule 类型 值 cargoownername 车主姓名 String birthday 车主生日 String
	 * yyyy-MM-dd qq qq号 String wechatid 微信号 String licenseplate 车牌号 String
	 * idcardno 身份证号 String cartype 汽车类型 String file1 头像 图片 file2 驾驶证 图片 file3
	 * 行驶证 图片
	 */
	// Map<String, String> infoMap = new HashMap<String, String>();

	/** 全局图片 */
	// Map<String, String> imageMap = new HashMap<String, String>();

	/**
	 * 司机的驾驶证
	 */
	private ImageView driverCard;

	/**
	 * 司机的行驶证
	 */
	private ImageView travelCard;

	/**
	 * 司机身份证
	 */
	private ImageView driverIDCard;

	/**
	 * 车侧面照片
	 */
	private ImageView carSide;

	/**
	 * 车头照片
	 */
	private ImageView carTop;

	/**
	 * 车45
	 */
	private ImageView carHalf;

	private AppContent appContent;

	/**
	 * 底部的button 是否变成提交
	 */
	private boolean but_is_change = false;

	/**
	 * 生日
	 */
	private TextView birthday_EditText;
	/**
	 * 司机生日变量
	 */
	private String Birthday;
	// 图片在SD卡中的缓存路径

	/**
	 * 司机选择的区域个数
	 */
	private int oftenStayCount;

	/**
	 * 司机长跑的区域个数
	 */
	private int oftenRunCount;

	private static final String IMAGE_PATH = Environment
			.getExternalStorageDirectory().toString()
			+ File.separator
			+ "tczh"
			+ File.separator + "Images" + File.separator;

	private boolean isSave=false;
	
	/**
	 * 从服务器获得地区数据
	 */
	private List<AreaBeenFromServe> areaBeenFromServe = new ArrayList<AreaBeenFromServe>();

	@SuppressLint("NewApi")
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_message);
		appContent = (AppContent) getApplication();
		Intent intent = getIntent();
		if (intent != null) {
			String massage = intent.getStringExtra("message");
			if (massage != null && massage.length() > 0) {
				TextView message = (TextView) findViewById(R.id.drivermessage);
				message.setVisibility(View.VISIBLE);
				message.setText(massage);
			}
			reg = intent.getStringExtra("user_reg");
			if (reg != null) {

				if (reg.equals("注册")) {
					TextView head_right_text = (TextView) findViewById(R.id.head_right_text);
					head_right_text.setVisibility(View.VISIBLE);
					head_right_text.setTextColor(Color.WHITE);
					head_right_text.setText("跳过");
					login();
					head_right_text.setOnClickListener(new OnClickListener() {

						@Override
						public void onClick(View arg0) {
							// TODO Auto-generated method stub
							startActivity(new Intent(MessageActivity.this,
									ProjectHomeActivity.class));
							MessageActivity.this.finish();
							
						}
					});
					TextView message = (TextView) findViewById(R.id.drivermessage);
					message.setVisibility(View.VISIBLE);
					message.setText("亲爱的用户，只有认证信息审核通过的司机才能承接我们货物");

				}
			} else {
				ImageView left_image=(ImageView) findViewById(R.id.head_left);
				left_image.setVisibility(View.VISIBLE);
				left_image.setOnClickListener(new OnClickListener() {
					
					@Override
					public void onClick(View arg0) {
						// TODO Auto-generated method stub
						MessageActivity.this.finish();
					}
				});
				UserInfoBeen userInfo = appContent.userInfoBeen;
				if (userInfo != null) {

					if (userInfo.getChecked() != null) {
						if (userInfo.getChecked().equals("0")) {
							TextView message = (TextView) findViewById(R.id.drivermessage);
							message.setVisibility(View.VISIBLE);
							message.setTextColor(Color.rgb(225, 108, 0));
							message.setText("审核中");
						}
						if (userInfo.getChecked().equals("1")) {
							TextView message = (TextView) findViewById(R.id.drivermessage);
							message.setVisibility(View.VISIBLE);
							//
							message.setTextColor(Color.rgb(56, 204, 10));
							message.setText("审核通过,请注意如果重新提交信息系统将会重新审核");
						}
						if (userInfo.getChecked().equals("2")) {
							TextView message = (TextView) findViewById(R.id.drivermessage);
							message.setTextColor(Color.rgb(225, 108, 0));
							message.setVisibility(View.VISIBLE);
							message.setText("审核未通过");
						}
					}
				}
			}
		}
		Ini();
		initTitel(); // 初始化标题
		iniViewPage(); // 初始化viewpage
		if (savedInstanceState != null) {
			L.v("savedInstanceState", "要去获得数据");
			//infoMap
			isSave=true;
			 serializable_infoMap=(SerializableMap) savedInstanceState.getSerializable("infoMap");
		//	infobundle=serializable_infoMap.getMap();
			infobundle = savedInstanceState.getBundle("info");
			if (infobundle==null) {
				infobundle=new Bundle();
			}
			imagebundle = savedInstanceState.getBundle("image");
			pageNo = savedInstanceState.getInt("pageNo");
			mTakePicturePath = savedInstanceState.getString("mTakePicturePath");
			L.v("mTakePicturePath--->", mTakePicturePath);
//			if (mTakePicturePath!=null) {
//				L.v("mTakePicturePath--->", mTakePicturePath);
//			}else {
//				L.v("mTakePicturePath--->", "mTakePicturePath为空");
//			}
		//
		
			appContent.userInfoBeen = (UserInfoBeen) savedInstanceState
					.getSerializable("userinfo");
		} else {
			imageMap = new HashMap<String, String>();
			infoMap = new HashMap<String, Object>();
			infobundle = new Bundle();
			imagebundle = new Bundle();
			serializable_infoMap = new SerializableMap();
			
		}
		getUserInfoBennFromService();
		if (pageNo==0) {
			Button t=(Button) findViewById(R.id.back);
			t.setVisibility(View.GONE);
		}
		
	}

	/**
	 * 
	 * @Title: RecoveryData
	 * @Description: TODO(恢复activity被回收前的数据)
	 * @param @param info
	 * @param @param image 参数说明
	 * @return void 返回类型
	 * @throws
	 */
	private void RecoveryData(SerializableMap info, Bundle image) {
		//Set<String> i = info.keySet();
		Set<String> m = image.keySet();
		//serializable_infoMap =info.get("infoMap");
		infoMap = info.getMap();
		if (infoMap==null) {
			infoMap=new HashMap<String, Object>();
		}
//		for (String key : i) {
//			infoMap.put(key, info.getString(key));
//			L.v("info转存储的数据", "key:" + key + ";Vaule:" + info.getString(key));
//		}
		BitmapUtils utils = new BitmapUtils(this);
		imageMap=new HashMap<String, String>();
		for (String key : m) {
			imageMap.put(key, image.getString(key));
			L.v("imageMap转存储的数据",
					"key:" + key + ";Vaule:" + image.getString(key));
			if (key.equals("file1")) {
				if (user_head != null) {
					utils.display(user_head, image.getString("file1"));
				} else {
					L.v("user_head", "是空");
				}

			}
			if (key.equals("file2")) {
				if (driverCard != null) {
					utils.display(driverCard, image.getString("file2"));
				} else {
					L.v("driverCard", "是空");
				}

			}
			if (key.equals("file3")) {
				if (travelCard != null) {
					utils.display(travelCard, image.getString("file3"));
				} else {
					L.v("travelCard", "是空");
				}

			}
			if (key.equals("file4")) {
				if (driverIDCard != null) {
					utils.display(driverIDCard, image.getString("file4"));
				} else {
					L.v("driverIDCard", "是空");
				}

			}
			if (key.equals("file5")) {
				if (carTop != null) {
					utils.display(carTop, image.getString("file5"));
				} else {
					L.v("carTop", "是空");
				}

			}
			if (key.equals("file6")) {
				if (carSide != null) {
					utils.display(carSide, image.getString("file6"));
				} else {
					L.v("carSide", "是空");
				}

			}
			if (key.equals("file7")) {
				if (carHalf != null) {
					utils.display(carHalf, image.getString("file7"));
				} else {
					L.v("carHalf", "是空");
				}

			}

		}

		if (pageNo == 0) {
			String name = (String) infoMap.get("cargoownername");
			if (name != null) {
				realName_EditText.setText(name);
			}

		}

		if (pageNo == 0) {
			String cargoownername=(String) infoMap.get("cargoownername");
			String idcardno=(String) infoMap.get("idcardno");
			String licenseplate=(String) infoMap.get("licenseplate");
			if (!TextUtils.isEmpty(cargoownername)) {
				realName_EditText.setText(cargoownername);
			}
			if (!TextUtils.isEmpty(idcardno)) {
				ID_EditText.setText(idcardno);
			}
			if (!TextUtils.isEmpty(licenseplate)) {
				carTag_EditText.setText(licenseplate);
			}
			
			
			List<Area> oftenRun = (List<Area>) infoMap.get("oftenRun");
			String oftenrunsString = "";
			if (oftenRun!=null) {	
			for (int j = 0; j < oftenRun.size(); j++) {
				oftenrunsString = oftenrunsString
						+ oftenRun.get(j).getAreaname() + "；";
			}
			oftenRun_EditText.setText(oftenrunsString);
			}
			List<Area> oftenStay = (List<Area>) infoMap.get("oftenStay");
			String oftenString = "";
			if (oftenStay!=null) {
			for (int k = 0; k < oftenStay.size(); k++) {
				oftenString = oftenString + oftenStay.get(k).getAreaname()
						+ "；";
			}
			oftenStay_EditText.setText(oftenString);
			}
			// 还原数据
			CarTypeBeen t = (CarTypeBeen) infoMap.get("cartype");
			
			
			if ( t!=null) {
				carType_EditText.setText(t.getCartypename());
			}
			
		}
		if (pageNo == 1) {
			String birthday = (String) infoMap.get("birthday");
			if (birthday != null) {
				// gender_EditText.setText(birthday);
			}
			String qq = (String) infoMap.get("qq");
			if (qq != null) {
				QQ_EditText.setText(qq);
			}
			String wechatid = (String) infoMap.get("wechatid");
			if (wechatid != null) {
				weixin_EditText.setText(wechatid);
			}

		}
	}

	/**
	 * 
	 * @Title: SetDataToUI
	 * @Description: TODO(将服务器中的数据赋值上来)
	 * @param @param userInfoBeen 参数说明
	 * @return void 返回类型
	 * @throws
	 */
	private void SetDataToUI(MessageBeen data) {

		// gender_EditText.setText(userInfoBeen.getBirthday());
		if (data.getQq() != null && data.getQq().length() > 0) {
			QQ_EditText.setText(data.getQq());
		}

		if (data.getWechatid() != null && data.getWechatid().length() > 0) {
			weixin_EditText.setText(data.getWechatid());
		}

		if (data.getCartypename() != null && data.getCartypename().length() > 0) {
			// 车类型
			carType_EditText.setText(data.getCartypename());
		}

		if (data.getLicenseplate() != null
				&& data.getLicenseplate().length() > 0) {
			// 车牌
			carTag_EditText.setText(data.getLicenseplate());
		}

		if (data.getOftenRun() != null && data.getOftenRun().length() > 0) {

			// 常跑和常在都有

			oftenRun_EditText.setText(data.getOftenRun());

		}
		if (data.getOftenStay() != null && data.getOftenStay().length() > 0) {
			oftenStay_EditText.setText(data.getOftenStay());
		}

		if (data.getCargoownername() != null
				&& data.getCargoownername().length() > 0) {
			realName_EditText.setText(data.getCargoownername());
		}

		if (data.getIdcardno() != null && data.getIdcardno().length() > 0) {
			ID_EditText.setText(data.getIdcardno());
		}
		String rootpath = SD_Finder.GetPaht();
		rootpath = rootpath + GagApi.IMAGE_FILE_PATH;
		BitmapUtils u_bitmap = new BitmapUtils(this, rootpath);
		if (data.getDrivinglicenceurl() != null
				&& data.getDrivinglicenceurl().length() > 0) {

			u_bitmap.display(driverCard,
					GagApi.IMAGE_PAHT_HOST + data.getDrivinglicenceurl());

		}

		if (data.getDrivinglicenceurl2() != null
				&& data.getDrivinglicenceurl2().length() > 0) {

			u_bitmap.display(travelCard,
					GagApi.IMAGE_PAHT_HOST + data.getDrivinglicenceurl2());
		}

		if (data.getHeadportrait() != null
				&& data.getHeadportrait().length() > 0) {

			u_bitmap.display(user_head,
					GagApi.IMAGE_PAHT_HOST + data.getHeadportrait());

		}

		if (data.getCarfacephoto() != null
				&& data.getCarfacephoto().length() > 0) {

			// 车头
			// drive_EditText
			u_bitmap.display(carTop,
					GagApi.IMAGE_PAHT_HOST + data.getCarfacephoto());
		}

		if (data.getIdcardphoto() != null && data.getIdcardphoto().length() > 0) {

			// 身份证
			// BitmapUtils u = new BitmapUtils(this);
			u_bitmap.display(driverIDCard,
					GagApi.IMAGE_PAHT_HOST + data.getIdcardphoto());
		}

		if (data.getCarsidephoto() != null
				&& data.getCarsidephoto().length() > 0) {

			// 车侧面
			u_bitmap.display(carSide,
					GagApi.IMAGE_PAHT_HOST + data.getCarsidephoto());
		}
		if (data.getCarotherphoto() != null
				&& data.getCarotherphoto().length() > 0) {

			// 车45
			u_bitmap.display(carHalf,
					GagApi.IMAGE_PAHT_HOST + data.getCarotherphoto());

		}

		// u.display(container, uri);
		if (data.getBirthday() != null && data.getBirthday().length() > 0) {
			birthday_EditText.setText(data.getBirthday());
		}
		// oftenAddressList = new ArrayList<Map<String, Object>>();
		if (data.getOftenRunId() != null && data.getOftenRunId().length() > 0) {
			String[] strArray = null;

			strArray = data.getOftenRunId().split(",");// (data.getOftenRunId());
			oftenRunCount = strArray.length;
			for (int i = 0; i < strArray.length; i++) {
				// Map<String, Object> dat = new HashMap<String, Object>();
				L.v("获得的OftenRunId", strArray[i]);
				AreaBeenFromServe aBeenFromServe = new AreaBeenFromServe();
				aBeenFromServe.setAreaid(strArray[i]);
				aBeenFromServe.setType("0");
				areaBeenFromServe.add(aBeenFromServe);
				// dat.put("areaid", strArray[i]);
				// dat.put("type", "0");
				// oftenAddressList.add(dat);
			}
		}

		if (data.getOftenStayId() != null && data.getOftenStayId().length() > 0) {
			String[] strArray = null;
			strArray = data.getOftenStayId().split(",");
			oftenStayCount = strArray.length;
			for (int i = 0; i < strArray.length; i++) {

				AreaBeenFromServe aBeenFromServe = new AreaBeenFromServe();
				aBeenFromServe.setAreaid(strArray[i]);
				aBeenFromServe.setType("1");
				areaBeenFromServe.add(aBeenFromServe);
			}
		}
		L.v("SetDataToUI", "SetDataToUI完成");
		if (isSave) {
			RecoveryData(serializable_infoMap, imagebundle);
		}
		
	}

	/**
	 * 下载图片到SD卡
	 * 
	 * 
	 */

	private void DownLoadImage(String url) {
		HttpJsonTool httpJsonTool = new HttpJsonTool(this);
		httpJsonTool.SetOnLister(new Handler() {
			@Override
			public void handleMessage(Message msg) {
				// TODO Auto-generated method stub
				super.handleMessage(msg);
			}
		});
		// httpJsonTool.StartWork(data, url, null, null);
	}

	/**
	 * 
	 * @Title: Ini
	 * @Description: TODO(配置信息)
	 * @param 参数说明
	 * @return void 返回类型
	 * @throws
	 */
	private void Ini() {
		// appContent = (AppContent) getApplication();

		messageTab0 = (TextView) findViewById(R.id.must_message);
		messageTab1 = (TextView) findViewById(R.id.car_message);

		// 上面buttion点击不需要现在
		messageTab0.setBackgroundColor(Color.parseColor("#FFD700"));
		// messageTab0.setOnClickListener(new GuideButtonClickListener(0));
		// messageTab1.setOnClickListener(new GuideButtonClickListener(1));
		// messageTab2.setOnClickListener(new GuideButtonClickListener(2));
		viewPager = (CustomViewPager) findViewById(R.id.orderdetails_viewpager);
		buttons = new TextView[2];
		buttons[0] = messageTab0;
		buttons[1] = messageTab1;

	}

	private void iniViewPage() {
		inflater = getLayoutInflater();
		pageViews = new ArrayList<View>();
		first = inflater.inflate(R.layout.most_message, null);

		second = inflater.inflate(R.layout.car_message, null);

		pageViews.add(first);
		pageViews.add(second);

		// 第一页
		realName_EditText = (EditText) first
				.findViewById(R.id.realName_EditText);
		viewPager.setAdapter(new OrderViewPageAdapter());
		viewPager.setOnPageChangeListener(new OrderPageChangeListener());
		// 驾驶证sd
		driverCard = (ImageView) first.findViewById(R.id.drive_EditText);
		driverCard.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				TakePicture(1);
			}
		});
		// 行驶证
		travelCard = (ImageView) first.findViewById(R.id.run_EditText);
		travelCard.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				TakePicture(2);
			}
		});
		// 身份证明
		driverIDCard = (ImageView) first.findViewById(R.id.car_id);
		driverIDCard.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				TakePicture(4);
			}
		});

		// 车头
		carTop = (ImageView) first.findViewById(R.id.cartop);
		carTop.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				TakePicture(5);
			}
		});
		// 车侧面
		carSide = (ImageView) first.findViewById(R.id.carside);
		carSide.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				TakePicture(6);
			}
		});
		// 车45度
		carHalf = (ImageView) first.findViewById(R.id.carhalf);
		carHalf.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				TakePicture(7);
			}
		});
		/**
		 * 
		 */

		realName_EditText = (EditText) first
				.findViewById(R.id.realName_EditText);
		ID_EditText = (EditText) first.findViewById(R.id.ID_EditText);
		carTag_EditText = (EditText) first.findViewById(R.id.carTag_EditText);

		oftenRun_EditText = (TextView) first
				.findViewById(R.id.oftenRun_EditText);
		oftenRun_EditText.setOnClickListener(this);
		oftenStay_EditText = (TextView) first
				.findViewById(R.id.oftenStay_EditText);
		oftenStay_EditText.setOnClickListener(this);
		carType_EditText = (TextView) first.findViewById(R.id.carType_EditText);
		carType_EditText.setOnClickListener(this);
		// ******************************************************************************

		// 第二页
		// 用户头像
		QQ_EditText = (EditText) second.findViewById(R.id.QQ_EditText);
		user_head = (ImageView) second.findViewById(R.id.user_head);
		birthday_EditText = (TextView) second
				.findViewById(R.id.birthday_EditText);

		/**
		 * 司机生日选择
		 */
		birthday_EditText.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Setbirthday(birthday_EditText);
			}
		});
		weixin_EditText = (EditText) second.findViewById(R.id.weixin_EditText);
		user_head.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				TakePicture(3);
			}
		});

		Button back = (Button) findViewById(R.id.back);
		Button next = (Button) findViewById(R.id.next);
		back.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub

				if (pageNo > 0) {
					viewPager.setCurrentItem(pageNo - 1);
				}

			}
		});
		next.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub

				if (pageNo < 1) {
					viewPager.setCurrentItem(pageNo + 1);
				}

			}
		});

	}

	/**
	 * 
	 * @Title: getUserInfoBennFromService
	 * @Description: TODO(保存数据)
	 * @param 参数说明
	 * @return void 返回类型
	 * @throws
	 */
	private void getUserInfoBennFromService() {
		/**
		 * 获得用户信息
		 */
	//	showLoadingDialog("数据加载中");
		UserInfoBeen userInfoBeen = appContent.userInfoBeen;
		if (userInfoBeen != null) {
			HashMap<String, Object> data = new HashMap<String, Object>();
			data.put("carownerid", userInfoBeen.getCarownerid() + "");
			HttpJsonTool httpJsonTool = new HttpJsonTool(this);
			httpJsonTool.SetOnLister(new Handler() {
				@Override
				public void handleMessage(Message msg) {
					// TODO Auto-generated method stub
					super.handleMessage(msg);
				//	dismissLoadingDialog();
					if (msg.what == 1) {
						// MessageBeen
						List<MessageBeen> datamess = (List<MessageBeen>) msg.obj;
						if (datamess.size() > 0) {
							SetDataToUI(datamess.get(0));
						}

					}
				}
			});
			Type type = new TypeToken<List<MessageBeen>>() {
			}.getType();
			httpJsonTool.StartWork(data, GagApi.DRIVER_MESSAGE_GET, type, null);
		}else {
			dismissLoadingDialog();
		}
	}

	private void initTitel() {
		TextView title = (TextView) findViewById(R.id.head_title);
		String a;
		if (appContent.userInfoBeen != null) {
			if (appContent.userInfoBeen.getChecked() != null) {
				a = appContent.userInfoBeen.getChecked();
				if (a == "1") {
					title.setText("验证信息通过");
				} else if (a == "2") {
					title.setText("验证信息未通过");
				} else {
					title.setText("信息验证");
				}
			}
		} else {

			title.setText("信息验证");
		}

		// if (appContent.userInfoBeen.) {

		// }

	}

	class OrderViewPageAdapter extends PagerAdapter {

		@Override
		public int getCount() {
			// TODO Auto-generated method stub
			return pageViews.size();
		}

		@Override
		public boolean isViewFromObject(View arg0, Object arg1) {
			// TODO Auto-generated method stub
			return arg0 == arg1;
		}

		@Override
		public int getItemPosition(Object object) {
			// TODO Auto-generated method stub
			return super.getItemPosition(object);
		}

		@Override
		public void destroyItem(View container, int position, Object object) {
			// TODO Auto-generated method stub

			((ViewPager) container).removeView(pageViews.get(position));

		}

		@Override
		public Object instantiateItem(View container, int position) {
			// TODO Auto-generated method stub
			((ViewPager) container).addView(pageViews.get(position));
			return pageViews.get(position);
		}

	}

	class OrderPageChangeListener implements OnPageChangeListener {

		@Override
		public void onPageScrollStateChanged(int arg0) {
			// TODO Auto-generated method stub

		}

		@Override
		public void onPageScrolled(int arg0, float arg1, int arg2) {
			// TODO Auto-generated method stub

		}

		/*
		 * (non-Javadoc)
		 * 
		 * @see
		 * android.support.v4.view.ViewPager.OnPageChangeListener#onPageSelected
		 * (int)
		 * 
		 * KEY KEY说明 Vaule 类型 值 cargoownername 车主姓名 String birthday 车主生日 String
		 * yyyy-MM-dd qq qq号 String wechatid 微信号 String licenseplate 车牌号 String
		 * idcardno 身份证号 String cartype 汽车类型 String file1 头像 图片 file2 驾驶证 图片
		 * file3 行驶证 图片
		 */

		@Override
		public void onPageSelected(int arg0) {
			// TODO Auto-generated method stub
			// L.v("onPageSelected", "" + arg0);
			L.v("arg0", "" + pageNo);
			pageNo = arg0;
			InforVerify(arg0 - 1);
			if (but_is_change) {
				if (arg0 != 1) {
					Button t=(Button) findViewById(R.id.back);
					t.setVisibility(View.GONE);
					Button s = (Button) findViewById(R.id.next);
					s.setText("下一步");
					s.setOnClickListener(new OnClickListener() {

						@Override
						public void onClick(View arg0) {
							// TODO Auto-generated method stub
							if (pageNo < 1) {
								viewPager.setCurrentItem(pageNo + 1);
							}
						}
					});
				}
			}

			L.v("pageNo", "" + pageNo);

			for (int i = 0; i < buttons.length; i++) {
				buttons[arg0].setBackgroundColor(Color.parseColor("#FFD700"));
				if (arg0 != i) {
					L.v("出来", "" + i);
					buttons[i].setBackgroundColor(Color.parseColor("#F5F5DC"));
				}
			}

			if (arg0 == 1) {
				but_is_change = true;
				Button s = (Button) findViewById(R.id.next);
				s.setText("提交");
				s.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View arg0) {
						// TODO Auto-generated method stub
						UpLoadMessage();
					}
				});
				Button t=(Button) findViewById(R.id.back);
				t.setVisibility(View.VISIBLE);
			}
		}

	}

	/**
	 * 
	 * @Title: Setbirthday 司机选择生日
	 * @Description: TODO(司机选择生日)
	 * @param 参数说明
	 * @return void 返回类型
	 * @throws
	 */
	private void Setbirthday(TextView birthday_EditText) {
		// Calendar calendar=Calendar.getInstance(Locale.CHINA);
		// Date date=new Date();
		// calendar.setTime(date);
		String initDataTime = "1985年1月1日";
		DatePickerFragment datePickerFragment = new DatePickerFragment(this,
				initDataTime, false);
		datePickerFragment.setOnChoseData(new onChoseData() {

			@Override
			public void getChoseData(String dataString) {
				// TODO Auto-generated method stub
				L.v("birthday", dataString);
				infoMap.put("birthday", dataString);
				infobundle.putString("birthday", Birthday);
			}
		});
		datePickerFragment.dateTimePicKDialog(birthday_EditText);

	}

	// /**
	// *
	// * @Title: onDateSet
	// * @Description: TODO(获得弹出的时间转轮)
	// * @param @param arg0
	// * @param @param arg1
	// * @param @param arg2
	// * @param @param arg3 参数说明
	// * @return void 返回类型
	// * @throws
	// */
	// @Override
	// public void onDateSet(DatePicker view, int year, int monthOfYear,
	// int dayOfMonth) {
	// // TODO Auto-generated method stub
	// // 月要加一个
	// L.v("选择的时间-->", "" + year + "/" + monthOfYear + "/" + dayOfMonth);
	// if (monthOfYear < 10) {
	// if (dayOfMonth < 10) {
	// Birthday = year + "-0" + (monthOfYear + 1) + "-0" + dayOfMonth;
	// } else {
	//
	// Birthday = year + "-0" + (monthOfYear + 1) + "-" + dayOfMonth;
	// }
	// } else {
	// if (dayOfMonth < 10) {
	// Birthday = year + "-" + (monthOfYear + 1) + "-0" + dayOfMonth;
	// } else {
	// Birthday = year + "-" + (monthOfYear + 1) + "-" + dayOfMonth;
	// }
	//
	// }
	// infoMap.put("birthday", Birthday);
	// // infoMap.put(arg0, Birthday);
	// infobundle.putString("birthday", Birthday);
	// birthday_EditText.setText(Birthday);
	// L.v("获得的", Birthday);
	// }

	/**
	 * 
	 * @Title: InforVerify
	 * @Description: TODO(验证每一页的信息)
	 * @param @param arg0
	 * @param @return 参数说明 true为验证成功
	 * @return boolean 返回类型
	 * @throws
	 */
	private void InforVerify(int arg0) {

		if (arg0 == 0) {
			/** 车主姓名 */
			String name = realName_EditText.getText().toString().trim();

			if (name != null && name.length() > 1) {

				// Toast.makeText(MessageActivity.this, "请输入您的姓名",
				// Toast.LENGTH_LONG).show();
				// return false;
				infoMap.put("cargoownername", name);
				infobundle.putString("cargoownername", name);
			}

			/**
			 * 保存name
			 */

			/**
			 * ID
			 */
			String ID = ID_EditText.getText().toString();
			if (ID != null && ID.length() == 18) {
				infoMap.put("idcardno", ID);
				infobundle.putString("idcardno", ID);
			}

			/**
			 * 车牌号
			 */
			String licenseplate = carTag_EditText.getText().toString().trim();
			if (licenseplate != null && licenseplate.length() > 1) {
				infoMap.put("licenseplate", licenseplate);
				infobundle.putString("licenseplate", licenseplate);
			}

		}

	}

	/**
	 * 用户拍照上传相关信息 使用相机时候设定文件的路径和名字 使用相册的时候需要在在intent中去获得
	 * swithTpyeCard是司机上传的那个证件照片 1为驾驶证明 2为行驶证明
	 */
	private void TakePicture(final int swithTpyeCard) {
		new AlertDialog.Builder(MessageActivity.this)
				.setTitle("证件图片选择")
				.setItems(new String[] { "拍照上传照片", "上传手机中的照片" },
						new DialogInterface.OnClickListener() {

							public void onClick(DialogInterface dialog,
									int which) {
								Intent intent = null;
								System.out.println("addImg=mark22-------"
										+ typeMark);

								switch (which) {
								case 0:

									FileUtils.createDirFile(IMAGE_PATH);
									intent = new Intent(
											MediaStore.ACTION_IMAGE_CAPTURE);
									String path = IMAGE_PATH
											+ UUID.randomUUID().toString()
											+ ".jpg";
									mTakePicturePath = path;
									File file = FileUtils.createNewFile(path);
									if (file != null) {
										intent.putExtra(
												MediaStore.EXTRA_OUTPUT,
												Uri.fromFile(file));
									}
									if (swithTpyeCard == 1) {
										startActivityForResult(intent,
												INTENT_REQUEST_CODE_CAMERA_FOR_DRIVERCARD);
									}
									if (swithTpyeCard == 2) {
										startActivityForResult(intent,
												INTENT_REQUEST_CODE_CAMERA_FOR_TRAVELCARD);
									}
									if (swithTpyeCard == 3) {
										startActivityForResult(intent,
												INTENT_REQUEST_CODE_CAMERA_FOR_DRIVERHEADIMAGE);
									}
									if (swithTpyeCard == 4) {
										startActivityForResult(intent,
												INTENT_REQUEST_CODE_CAMERA_FOR_DRIVERID);
									}
									if (swithTpyeCard == 5) {
										startActivityForResult(intent,
												INTENT_REQUEST_CODE_CAMERA_FOR_CARTOP);
									}
									if (swithTpyeCard == 6) {
										startActivityForResult(intent,
												INTENT_REQUEST_CODE_CAMERA_FOR_CARSIDE);
									}
									if (swithTpyeCard == 7) {
										startActivityForResult(intent,
												INTENT_REQUEST_CODE_CAMERA_FOR_CARHALF);
									}

									break;

								case 1:

									Intent intent2 = new Intent(
											Intent.ACTION_PICK, null);
									intent2.setDataAndType(
											MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
											"image/*");
									if (swithTpyeCard == 1) {
										startActivityForResult(intent2,
												INTENT_REQUEST_CODE_ALBUM_FOR_DRIVERCARD);
									}
									if (swithTpyeCard == 2) {
										startActivityForResult(intent2,
												INTENT_REQUEST_CODE_ALBUM_FOR_TRAVELCARD);
									}

									if (swithTpyeCard == 3) {
										startActivityForResult(intent2,
												INTENT_REQUEST_CODE_ALBUM_FOR_DRIVERHEADIMAGE);
									}
									if (swithTpyeCard == 4) {
										startActivityForResult(intent2,
												INTENT_REQUEST_CODE_ALBUM_FOR_DRIVERID);
									}
									if (swithTpyeCard == 5) {
										startActivityForResult(intent2,
												INTENT_REQUEST_CODE_ALBUM_FOR_CARTOP);
									}
									if (swithTpyeCard == 6) {
										startActivityForResult(intent2,
												INTENT_REQUEST_CODE_ALBUM_FOR_CARSIDE);
									}
									if (swithTpyeCard == 7) {
										startActivityForResult(intent2,
												INTENT_REQUEST_CODE_ALBUM_FOR_CARHALF);
									}

									break;
								}
							}
						})
				.setNegativeButton("取消", new DialogInterface.OnClickListener() {

					public void onClick(DialogInterface dialog, int which) {
						dialog.cancel();
					}
				}).create().show();
	}

	/**
	 * 
	 * 如果是相册那么从intent获得url
	 * 
	 */
	private void GetDataFromIntentToMap(Intent data, String key) {
		Uri uri = data.getData();
		String[] proj = { MediaStore.Images.Media.DATA };
		Cursor cursor = managedQuery(uri, proj, null, null, null);
		if (cursor != null) {
			int column_index = cursor
					.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
			if (cursor.getCount() > 0 && cursor.moveToFirst()) {
				String path = cursor.getString(column_index);
				L.v("onActivityResult", "获得图片的地址-->" + path);

				// 压缩图片
				ImageFactory.compressImage(path, 10);

				// UpImageToService(key, path);
				// 放大content中
				if (imageMap==null) {
					imageMap=new HashMap<String, String>();
				}
				if (imagebundle==null) {
					imagebundle=new Bundle();
				}
				imageMap.put(key, path);
				imagebundle.putString(key, path);
				if (key.equals("file2")) {
					BitmapUtils utils = new BitmapUtils(this);
					utils.display(driverCard, path);
				}
				if (key.equals("file3")) {
					BitmapUtils utils = new BitmapUtils(this);
					utils.display(travelCard, path);
				}
				if (key.equals("file4")) {
					BitmapUtils utils = new BitmapUtils(this);
					utils.display(driverIDCard, path);
				}
				if (key.equals("file1")) {
					BitmapUtils utils = new BitmapUtils(this);
					utils.display(user_head, path);
				}
				if (key.equals("file5")) {
					BitmapUtils utils = new BitmapUtils(this);
					utils.display(carTop, path);
				}
				if (key.equals("file6")) {
					BitmapUtils utils = new BitmapUtils(this);
					utils.display(carSide, path);
				}
				if (key.equals("file7")) {
					BitmapUtils utils = new BitmapUtils(this);
					utils.display(carHalf, path);
				}
			}
		}
	}

	/**
	 * 将图片数据放入map
	 * 
	 */
	private void SetImageToMap(String key) {
		L.v("-------------------数据------------------",
				"--------------------数据------------------");
		L.v("SetImageToMap", "key=" + key + "mTakePicturePath="
				+ mTakePicturePath);
		if (mTakePicturePath == null) {
			return;
		}
		// 压缩图片
		ImageFactory.compressImage(mTakePicturePath, 10);
		if (imageMap==null) {
			imageMap=new HashMap<String, String>();
		}
		if (imagebundle==null) {
			imagebundle=new Bundle();
		}
		imageMap.put(key, mTakePicturePath);
		imagebundle.putString(key, mTakePicturePath);
		// UpImageToService(key, mTakePicturePath);
		// for (Map.Entry<String, Object> entry : infoMap.entrySet()) {
		// L.v("infoMap",
		// "key= " + entry.getKey() + " and value= "
		// + entry.getValue());
		// }
		for (Map.Entry<String, String> entry : imageMap.entrySet()) {
			L.v("imageMap",
					"key= " + entry.getKey() + " and value= "
							+ entry.getValue());
		}
		if (key.equals("file2")) {
			BitmapUtils utils = new BitmapUtils(this);
			utils.display(driverCard, mTakePicturePath);
		}
		if (key.equals("file3")) {
			BitmapUtils utils = new BitmapUtils(this);
			utils.display(travelCard, mTakePicturePath);
		}
		if (key.equals("file4")) {
			BitmapUtils utils = new BitmapUtils(this);
			utils.display(driverIDCard, mTakePicturePath);
		}
		if (key.equals("file1")) {
			BitmapUtils utils = new BitmapUtils(this);
			utils.display(user_head, mTakePicturePath);
		}
		if (key.equals("file5")) {
			BitmapUtils utils = new BitmapUtils(this);
			utils.display(carTop, mTakePicturePath);
		}
		if (key.equals("file6")) {
			BitmapUtils utils = new BitmapUtils(this);
			utils.display(carSide, mTakePicturePath);
		}
		if (key.equals("file7")) {
			BitmapUtils utils = new BitmapUtils(this);
			utils.display(carHalf, mTakePicturePath);
		}
	}

	private void UpImageToService() {
		appContent.AntLogin();
		if (imageMap.size() == 0) {
			dismissLoadingDialog();
			if (reg != null && reg.equals("注册")) {
				startActivity(new Intent(MessageActivity.this,
						ProjectHomeActivity.class));
			}

			MessageActivity.this.finish();
			return;
		}
		// showLoadingDialog("数据上传中请等待...");
		HttpJsonTool tool = new HttpJsonTool(this);
		HashMap<String, String> data = new HashMap<String, String>();
		data.put("carownerid", appContent.userId);
		tool.SetOnLister(new Handler() {
			@Override
			public void handleMessage(Message msg) {
				// TODO Auto-generated method stub
				super.handleMessage(msg);
				if (msg.what == 1) {
					Toast.makeText(MessageActivity.this, (String) msg.obj,
							Toast.LENGTH_LONG).show();
					
					dismissLoadingDialog();
					startActivity(new Intent(MessageActivity.this,
							ProjectHomeActivity.class));
					MessageActivity.this.finish();
				} else {
					Toast.makeText(MessageActivity.this, (String) msg.obj,
							Toast.LENGTH_LONG).show();
					dismissLoadingDialog();
				}
			}
		});
		L.v("图片的大小", imageMap.size() + "");
		tool.StartWork(data, GagApi.USER_INFO_VERIFY_FOR_IMAGE, null, imageMap);

	}

	public void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		L.v("返回的requestCode", "" + requestCode);
		L.v("返回的resultCode", "" + resultCode);
		if (resultCode == RESULT_OK) {
			if (!FileUtils.isSdcardExist()) {
				Toast.makeText(MessageActivity.this, "SD卡不存在请检查",
						Toast.LENGTH_LONG).show();
				return;
			}
			switch (requestCode) {
			// 相册驾驶证明
			case INTENT_REQUEST_CODE_ALBUM_FOR_DRIVERCARD: {
				// json定义 驾驶证明为file2
				GetDataFromIntentToMap(data, "file2");
				// 图片上传到服务器

			}
				break;
			// 相册的RequestCode用于行驶证的CodetravelCard
			case INTENT_REQUEST_CODE_ALBUM_FOR_TRAVELCARD: {
				// json定义 行驶证明为file3
				GetDataFromIntentToMap(data, "file3");

			}
				break;

			// 照相的RequestCode用于驾驶证的code
			case INTENT_REQUEST_CODE_CAMERA_FOR_DRIVERCARD: {

				SetImageToMap("file2");

			}
				break;

			// 照相的RequestCode用于行驶证的Code
			case INTENT_REQUEST_CODE_CAMERA_FOR_TRAVELCARD: {
				SetImageToMap("file3");
				// UpImageToService("file3", mTakePicturePath);
			}
				break;

			// 司机头像的上传照相的RequestCode
			case INTENT_REQUEST_CODE_CAMERA_FOR_DRIVERHEADIMAGE: {
				SetImageToMap("file1");
				// UpImageToService("file1", mTakePicturePath);
			}
				break;
			// 司机头像的上传 相册的RequestCode
			case INTENT_REQUEST_CODE_ALBUM_FOR_DRIVERHEADIMAGE: {
				GetDataFromIntentToMap(data, "file1");
			}
				break;
			// 司机身份证 相册的RequestCode
			case INTENT_REQUEST_CODE_ALBUM_FOR_DRIVERID: {
				GetDataFromIntentToMap(data, "file4");
			}
				break;
			// 司机身份证 相机的RequestCode
			case INTENT_REQUEST_CODE_CAMERA_FOR_DRIVERID: {
				SetImageToMap("file4");
				// UpImageToService("file4", mTakePicturePath);
			}
				break;
			// 汽车正面相册的RequestCode
			case INTENT_REQUEST_CODE_ALBUM_FOR_CARTOP: {
				GetDataFromIntentToMap(data, "file5");

			}
				break;
			// 汽车正面照片
			case INTENT_REQUEST_CODE_CAMERA_FOR_CARTOP: {
				SetImageToMap("file5");
				// UpImageToService("file5", mTakePicturePath);
			}
				break;
			case INTENT_REQUEST_CODE_ALBUM_FOR_CARSIDE: {
				GetDataFromIntentToMap(data, "file6");
			}
				break;
			case INTENT_REQUEST_CODE_CAMERA_FOR_CARSIDE: {
				SetImageToMap("file6");
				// UpImageToService("file6", mTakePicturePath);
			}
				break;
			case INTENT_REQUEST_CODE_ALBUM_FOR_CARHALF: {
				GetDataFromIntentToMap(data, "file7");
			}
				break;
			case INTENT_REQUEST_CODE_CAMERA_FOR_CARHALF: {
				SetImageToMap("file7");
				// UpImageToService("file7", mTakePicturePath);
			}
				break;

			default:
				break;
			}
		}
		if (resultCode == 1) {
			switch (requestCode) {
			case 200: {
				CarTypeBeen carTypeBeen = (CarTypeBeen) data
						.getSerializableExtra("car_type");
				L.v("车辆类型", carTypeBeen.getCartypeid() + "");
				infoMap.put("car_type", carTypeBeen);
				serializable_infoMap.setMap(infoMap);
				carType_EditText.setText(carTypeBeen.getCartypename());
				InforVerify(0);
			}
				break;
			case 201: {
				L.v("保存的是常驻", "保存的是常驻201");
				Bundle bundle = data.getExtras();
				// Area carHomeBeen=(Area)201
				// data.getSerializableExtra("CarRoutANDHome");
				if (bundle != null) {
					Set<String> keySet = bundle.keySet();
					String vale = "";
					List<Area> d = new ArrayList<Area>();
					int i = 0;
					for (String key : keySet) {
						// vale=vale+"；"+((Area)
						// bundle.getSerializable(key)).getAreaname();

						Area area = ((Area) bundle.getSerializable(key));
						vale = area.getAreaname() + "、" + vale;
						d.add(area);
						i++;
					}
					infoMap.put("oftenStay", d);
					serializable_infoMap.setMap(infoMap);
					// infobundle.putSerializable("oftenStay",
					// serializable_infoMap);
					oftenStay_EditText.setText(vale);
					InforVerify(0);
				}
			}
				break;
			case 202: {
				L.v("保存的是常跑", "保存的是常跑202");
				Bundle bundles = data.getExtras();
				if (bundles != null) {
					Set<String> keySet = bundles.keySet();
					String vales = "";
					List<Area> ds = new ArrayList<Area>();
					int i = 0;
					for (String key : keySet) {
						// vale=vale+"；"+((Area)
						// bundle.getSerializable(key)).getAreaname();

						Area area = ((Area) bundles.getSerializable(key));
						vales = area.getAreaname() + "、" + vales;
						ds.add(area);
						i++;
					}
					infoMap.put("oftenRun", ds);
					oftenRun_EditText.setText(vales);
					InforVerify(0);
				}
			}
				break;
			default:
				break;
			}
		}
	}

	private void UpLoadMessage() {
		// 长跑线路 0
		showLoadingDialog("信息上传中...");
		// List<E>
		// List<Map<String, Object>> oftenAddressList = new
		// ArrayList<Map<String, Object>>();
		List<Area> ofternrun = (List<Area>) infoMap.get("oftenRun");
		if (ofternrun != null) {
			// 查看是否有选过的地区
			boolean flag = false;
			List<String> ofr = new ArrayList<String>();
			for (int i = 0; i < ofternrun.size(); i++) {
				AreaBeenFromServe da = new AreaBeenFromServe();
				da.setAreaid(ofternrun.get(i).getAreaid() + "");
				da.setType("0");
				for (int s = 0; s < areaBeenFromServe.size(); s++) {
					if ((da.getAreaid().equals(
							areaBeenFromServe.get(s).getAreaid()) && (da
							.getType().equals(areaBeenFromServe.get(s)
							.getType())))) {
						flag = true;
					}
				}
				if (!flag) {
					areaBeenFromServe.add(da);
				}
				if (areaBeenFromServe.size() == 0) {
					areaBeenFromServe.add(da);
				}
			}
			// infoMap.put("oftenRun", ofr);
		}

		infoMap.put("carownerid", appContent.userId);
		// 常住地区 `1
		List<Area> oftentay = (List<Area>) infoMap.get("oftenStay");
		if (oftentay != null) {
			// 查看是否有选过的地区
			boolean flag = false;
			List<String> oftay = new ArrayList<String>();
			for (int i = 0; i < oftentay.size(); i++) {
				AreaBeenFromServe da = new AreaBeenFromServe();
				da.setAreaid(oftentay.get(i).getAreaid() + "");
				da.setType("1");
				L.v("areaBeenFromServe", areaBeenFromServe.size() + "长度");
				for (int s = 0; s < areaBeenFromServe.size(); s++) {
					if ((da.getAreaid().equals(
							areaBeenFromServe.get(s).getAreaid()) && (da
							.getType().equals(areaBeenFromServe.get(s)
							.getType())))) {
						flag = true;
					}
				}
				if (!flag) {
					areaBeenFromServe.add(da);
				}
				if (areaBeenFromServe.size() == 0) {
					areaBeenFromServe.add(da);
				}
			}
			// infoMap.put("oftenStay", oftay);
		}
		if (areaBeenFromServe.size() > 0) {

			infoMap.put("oftenAddressList", areaBeenFromServe);
		}
		// 车型
		CarTypeBeen cattype = (CarTypeBeen) infoMap.get("car_type");
		if (cattype != null) {
			infoMap.put("cartype", cattype.getCartypeid() + "");
		}

		// 其他数据
		// String birthday = birthday_EditText.getText().toString().trim();
		String qq = QQ_EditText.getText().toString().trim();
		String wechatid = weixin_EditText.getText().toString().trim();
		// infoMap.put("birthday", birthday);
		if (qq != null && qq.length() > 0l) {
			infoMap.put("qq", qq);
			infobundle.putString("qq", qq);

		}

		//
		// infobundle.putString("birthday", birthday);
		if (qq != null && qq.length() > 0) {
			infoMap.put("wechatid", wechatid);
			infobundle.putString("wechatid", wechatid);
		}

		L.v("--------------------json上传数据------------------",
				"--------------------json上传数据------------------");
		for (Map.Entry<String, Object> entry : infoMap.entrySet()) {
			L.v("infoMap",
					"key= " + entry.getKey() + " and value= "
							+ entry.getValue());
		}
		for (Map.Entry<String, String> entry : imageMap.entrySet()) {
			L.v("imageMap",
					"key= " + entry.getKey() + " and value= "
							+ entry.getValue());
		}
		HttpJsonTool httpJsonTool = new HttpJsonTool(this);
		httpJsonTool.SetOnLister(new Handler() {
			@Override
			public void handleMessage(Message msg) {
				// TODO Auto-generated method stub
				super.handleMessage(msg);
				if (msg.what == 1) {
					Toast.makeText(MessageActivity.this, (String) msg.obj,
							Toast.LENGTH_LONG).show();
					UpImageToService();
				} else {
					UpImageToService();
				}
			}
		});
		httpJsonTool.StartWork(infoMap, GagApi.USER_INFO_VERIFY, null, null);
	}

	private void login() {
		// new ArrayList<LoginUserInfo>();
		showLoadingDialog("操作中");
		String username = (String) SPUtils.get(this, "phone", "");
		String password = (String) SPUtils.get(this, "password", "");
		password = Base64Util.fromHex(password);
		if (username.isEmpty() || password.isEmpty()) {
			// 没有保存过的登录的信息
			dismissLoadingDialog();
			openActivity(UserLoginActivity.class);
			this.finish();
		} else {
			HashMap<String, Object> dataMap = new HashMap<String, Object>();
			dataMap.put("phone", username);
			dataMap.put("password", password);
			Type type = new TypeToken<List<UserInfoBeen>>() {
			}.getType();
			// SeaveUserInfo(dataMap);
			HttpJsonTool httpJsonToos = new HttpJsonTool(this);
			httpJsonToos.SetOnLister(new Handler() {
				@Override
				public void handleMessage(Message msg) {
					// TODO Auto-generated method stub
					super.handleMessage(msg);
					
					if (msg.what == 1) {
						// app.userInfoBeen
						List<UserInfoBeen> d = (List<UserInfoBeen>) msg.obj;
						appContent.userInfoBeen = d.get(0);
						appContent.userId = d.get(0).getCarownerid() + "";
						// SeaveUserInfo(dataMap);\
						dismissLoadingDialog();
					//	openActivity(ProjectHomeActivity.class);
					//	MessageActivity.this.finish();
					} else {
						dismissLoadingDialog();
						Toast.makeText(MessageActivity.this, (String) msg.obj,
								Toast.LENGTH_LONG).show();
						openActivity(UserLoginActivity.class);
						MessageActivity.this.finish();
						
					}
				}
			});
			httpJsonToos.StartWork(dataMap, GagApi.LOGIN, type, null);
		}
	}

	/**
	 * 如果activity被回收那么就保存现有的临时数据
	 */
	@Override
	protected void onSaveInstanceState(Bundle outState) {
		// TODO Auto-generated method stub
		L.v("onSaveInstanceState-->", "保存的数据" + mTakePicturePath);
		outState.putString("mTakePicturePath", mTakePicturePath);
		if (serializable_infoMap==null) {
			serializable_infoMap=new SerializableMap();
		}
		serializable_infoMap.setMap(infoMap);
		outState.putSerializable("infoMap", serializable_infoMap);
		Set<String> keySet = imagebundle.keySet();
		for (String key : keySet) {
			Object value = imagebundle.get(key);
			L.v("boundle保存的值-->", "" + (String) value);
		}
		outState.putBundle("image", imagebundle);
		outState.putInt("pageNo", pageNo);
		outState.putSerializable("userinfo", appContent.userInfoBeen);
		super.onSaveInstanceState(outState);
	}

	@Override
	public void onClick(View view) {
		// TODO Auto-generated method stub
		// 200是车型
		// 201是常驻地区
		// 202是常跑线路
		switch (view.getId()) {
		case R.id.oftenRun_EditText:
			InforVerify(0);
			Intent intent = new Intent(MessageActivity.this, CarRoute.class);
			intent.putExtra("WORK_TYPE", 202);
			intent.putExtra("oftenRunCount", oftenRunCount);
			startActivityForResult(intent, 202);
			break;

		case R.id.oftenStay_EditText:
			InforVerify(0);
			Intent intent2 = new Intent(MessageActivity.this, CarRoute.class);
			intent2.putExtra("WORK_TYPE", 201);
			intent2.putExtra("oftenStayCount", oftenStayCount);
			startActivityForResult(intent2, 201);
			break;
		case R.id.carType_EditText:
			InforVerify(0);
			Intent intent3 = new Intent(MessageActivity.this, CarType.class);
			intent3.putExtra("WORK_TYPE", 200);
			startActivityForResult(intent3, 200);
			break;
		default:
			break;
		}
	}

	// /**
	// *
	// * @author 陈修园 保存下数据用
	// */
	// private class AreaBeenFromServe {
	// private String areaid;
	// private String type;
	//
	// public String getAreaid() {
	// return areaid;
	// }
	//
	// public void setAreaid(String areaid) {
	// this.areaid = areaid;
	// }
	//
	// public String getType() {
	// return type;
	// }
	//
	// public void setType(String type) {
	// this.type = type;
	// }
	// }

}
